 package com.song.pj.common.web;

 import com.song.pj.common.exception.ServiceException;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.RestControllerAdvice;

 //@ControllerAdvice
// @ResponseBody
 @RestControllerAdvice//
public class GlobalExceptionHandler {
//    public String
@ExceptionHandler({ArrayIndexOutOfBoundsException.class})
public String doHandleArrayIndexOutOfBoundsException(ArrayIndexOutOfBoundsException e){
 return "数组下标越界";
}
  @ExceptionHandler({ArithmeticException.class})
  public String doHandleArithmeticException(ArithmeticException e){
   return "the exception msg is "+e.getMessage();
  }

  @ExceptionHandler({ServiceException.class})
  public String doHandleServiceException(ServiceException e){
   return "the exception msg is "+e.getMessage();
  }

  @ExceptionHandler({Throwable.class})
  public String doHandleRuntimeException(RuntimeException e){
   e.printStackTrace();
   //log.error(...);
   //给运维人员发短信
   //发运维人员发email
   //播放一段音乐(报警)
   return "系统维护中";
  }
}
